﻿using System.Text;
using Core.Domain.Lexems;

namespace Core.SyntaxAnalysis.Classes
{
    public class Unary : Expr
    {
        private readonly Expr m_expr;

        public Unary(Lexem lex, Expr expr)
        {
            m_expr = expr;
            Lex = lex;
        }

        public override DataType GetExprType()
        {
            return m_expr.GetExprType();
        }

        public override string ExprGenerate(StringBuilder s)
        {
            string r = m_expr.Generate(s);
            string v = Env.NextVariable();
            s.AppendLine(v + " = " + Lex.StrValue + " " + r);
            return v;
        }
    }
}